﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace YJKArch.MapNameTag
{
	public partial class MapNameTagForm : System.Windows.Forms.Form
	{
		public MapNameTagForm()
		{
			this.InitializeComponent();
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		private void MapNameTagForm_Load(object sender, EventArgs e)
		{
			Helper.AddCombItems(IListDate.FontFamily, this.cboMapNameFontType);
			Helper.AddCombItems(IListDate.FontFamily, this.cboFontType);
			this.rdbTradition.Checked = true;
			this.cboProportion.SelectedIndex = 0;
			this.FontType = this.cboMapNameFontType.SelectedItem.ToString();
			this.proportionSelect = this.cboProportion.SelectedItem.ToString().Trim();
			this.MapNameStr = "";
			this.ckbDisplayProportion.Checked = true;
			this.ckbDisplayProportion.Checked = true;
		}

		private void MapNameTagForm_MouseLeave(object sender, EventArgs e)
		{
			if (!base.ClientRectangle.Contains(base.PointToClient(Cursor.Position)))
			{
				int wMsg = 7;
				MapNameTagForm.SendMessage(MapNameTag._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			}
			else
			{
				base.Focus();
			}
			this.FontType = this.cboMapNameFontType.SelectedItem.ToString();
			this.proportionSelect = this.cboProportion.SelectedItem.ToString().Trim();
			this.MapNameStr = this.txtMapNameStr.Text;
		}

		private void rdbTradition_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdbTradition.Checked)
			{
				this.traditionOrNational = true;
				return;
			}
			this.traditionOrNational = false;
		}

		private void rdbNational_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdbNational.Checked)
			{
				this.traditionOrNational = false;
				return;
			}
			this.traditionOrNational = true;
		}

		private void ckbDisplayProportion_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbDisplayProportion.Checked)
			{
				this.isChecked = true;
				return;
			}
			this.isChecked = false;
		}

		private void cboMapNameFontType_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.FontType = this.cboMapNameFontType.SelectedItem.ToString().Trim();
		}

		private void cboFontType_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.proportionFontType = this.cboFontType.SelectedItem.ToString();
		}

		private void txtMapNameStr_TextChanged(object sender, EventArgs e)
		{
			this.MapNameStr = this.txtMapNameStr.Text;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			System.Windows.Forms.TextBox textBox = this.txtMapNameStr;
			textBox.Text += "°";
		}

		private void button2_Click(object sender, EventArgs e)
		{
			System.Windows.Forms.TextBox textBox = this.txtMapNameStr;
			textBox.Text += "±";
		}

		private void button3_Click(object sender, EventArgs e)
		{
			System.Windows.Forms.TextBox textBox = this.txtMapNameStr;
			textBox.Text += "φ";
		}

		private void button4_Click(object sender, EventArgs e)
		{
			System.Windows.Forms.TextBox textBox = this.txtMapNameStr;
			textBox.Text += "%";
		}

		public string FontType;

		public string MapNameStr;

		public bool traditionOrNational = true;

		public string proportionSelect;

		public bool isChecked = true;

		public string proportionFontType;
	}
}
